﻿@using Webdiyer.WebControls.Mvc
@model Webdiyer.WebControls.Mvc.PagedList<WeChatService.Models.efmodel.Message>
@{
    Layout = null;
    
}

<!DOCTYPE html>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link href="@Url.Content("~/Content/assets/css/bootstrap.min.css")" rel="stylesheet" type="text/css"/>
        <link href="@Url.Content("~/Content/assets/css/font-awesome.min.css")" rel="stylesheet" type="text/css" />
        <link href="@Url.Content("~/Content/assets/css/ace.min.css")" rel="stylesheet" type="text/css" />
        <link href="@Url.Content("~/Content/assets/css/ace-rtl.min.css")" rel="stylesheet" type="text/css" />
        <link href="@Url.Content("~/Content/assets/css/ace-skins.min.css")" rel="stylesheet" type="text/css" />
        <link href="@Url.Content("~/Content/css/wechat.css")" rel="stylesheet" type="text/css" />

        <script src="@Url.Content("~/Content/assets/js/jquery-2.0.3.min.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Content/assets/js/ace-extra.min.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Content/assets/js/bootstrap.min.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Content/assets/js/typeahead-bs2.min.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Content/assets/js/ace-elements.min.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Content/assets/js/ace.min.js")" type="text/javascript"></script>
    </head>
<body>
    <div>
        <div class="input-group">
            <input id="search_key" class="form-control search-query" placeholder="搜索关键字" type="text" value="@ViewBag.serkey"/>
            <span class="input-group-btn">
                <button id="search_button" type="button" class="btn btn-purple btn-sm">
                    搜一搜
                    <i class="icon-search icon-on-right bigger-110"></i>
                </button>
            </span>
        </div>
        <div class="table-responsive">
            <table class="table table-striped table-bordered table-hover">
                <thead>
                    <tr>
                        <th class="center"></th>
                        <th>编号</th>
                        <th>标题</th>
                        <th>类型</th>
                    </tr>
                </thead>

                <tbody>
                    @{
                        if (Model != null && Model.Any())
                        {
                            foreach (var item in Model)
                            {
                                <tr>
                                    <td><input id="cb-@item.ID" type="checkbox" onclick="changeSelList(@item.ID);"/></td>
                                    <td>@item.ID</td>
                                    <td>@item.Title</td>
                                    <td>@item.Type</td>
                                </tr>
                            }
                        }
                    }
                </tbody>
            </table>
        </div>
        <div style="height: 100px; line-height: 50px; clear: both; " align="center">
            @Html.Pager(Model,
                        new PagerOptions
                            {
                                CssClass = "page_a",
                                PageIndexParameterName = "pageIndex",
                                ShowPageIndexBox = false,
                                PageIndexBoxType = PageIndexBoxType.DropDownList,
                                ShowGoButton = false,
                            })
        </div>
        <input type="hidden" id="sel_item_id" value="test"/>
    </div>
    
    <script type="text/javascript">
        jQuery(function($) {
            $("#search_button").on(ace.click_event, function() {
                var key = $.trim($('#search_key').val());
                if (key.length >= 20) {
                    key = key.substr(0, 20);
                }
                var type = @ViewBag.type;
                window.location.href = "/Message/Simple?serkey=" + key + "&type=" + type;
            });
        });

        function changeSelList(id) {
            if ($("#cb-" + id).is(':checked')) {
                //alert(id + "被选");
                var nowval = parent.$('#autoresp_msgid').val();
                var type = @ViewBag.type;
                if (type == "4") {
                    if ((nowval.split(';')).length - 1 < 5) {
                        parent.$('#autoresp_msgid').val(nowval + id + ";");
                    } else {
                        parent.layer.msg('最多只能选5项');
                    }
                } else {
                    parent.$('#autoresp_msgid').val(id);
                }
            } else {
                //alert(id + "被取消");
                var nowval = parent.$('#autoresp_msgid').val();
                var type = @ViewBag.type;
                if (type == "4") {
                    parent.$('#autoresp_msgid').val(nowval.replace((id + ";"),''));
                } else {
                    parent.$('#autoresp_msgid').val(nowval.replace(id,''));
                }
            }
        }
    </script>
</body>
</html>
